#! /usr/bin/env python
# -*- coding: utf-8 -*-

'''
界面逻辑
'''


import time
import Tkinter as tk


from tools import LoginUI
from tools import LineUi
from tools import sqltool2



class MainLoginUI(LoginUI.LoginUI):
    def __init__(self, master=None):
        super(MainLoginUI, self).__init__()
        self.root = master

    def Login(self):
        '''
        登录
        '''
        self.username = self.userStr.get().strip()
        self.password = self.passwdStr.get().strip()
        iu = (self.userStr.get(),self.passwdStr.get())
        i=[0]
        sqltool2.con(iu,i)
        print i[0]
        if i[0]==1:
            self.root.destroy()
            self.enter_m()
        

    def enter_m(self):
        root = tk.Tk()
        root.title("Main Context")
        MainLineUi(master=root)
        root.resizable(False, False)
        root.mainloop()
class MainLineUi(LineUi.LineUi):
    def __init__(self, master=None, **kv):
        super(MainLineUi, self).__init__()
        self.root = master
         

if __name__ == '__main__':
    '''
    main loop
    '''
    root = tk.Tk()
    root.title("Login")

    w = root.winfo_screenwidth()
    h = root.winfo_screenheight()
    rootsize = (396, 214)
    x = w/2 - rootsize[0]/2
    y = h/2 - rootsize[1]/2
    root.geometry("%dx%d+%d+%d" % (rootsize + (x, y)))

    MainLoginUI(master=root)
    root.resizable(False, False)
    root.mainloop()
